/*
 *  Shack Scripts RTE
 *  $Rev$
 *  $Author$
 *  $LastChangedDate$
 * 
 */


if (contentWindow.script_enabled('post_preview') == 'true') {

    function createPreviewArea() {
        var previewArea, main;
        previewArea = document.createElement('div');
        previewArea.id = 'previewArea';
        previewArea.style.display = 'block';
        previewArea.style.padding = 3 + 'px';
        previewArea.style.borderColor = '#AEAE9B';
        previewArea.style.borderWidth = 1 + 'px';
        previewArea.style.marginTop = 1 + 'px';
        previewArea.style.marginBottom = 1 + 'px';
        previewArea.style.borderStyle = 'solid';
        previewArea.style.backgroundColor = '#222222';
        previewArea.style.height = 230 + 'px';
        previewArea.style.width = 570 + 'px';
        previewArea.style.overflow = 'auto';
        previewArea.contentEditable = true;
        previewArea.onkeyup = testfunc;
        contentWindow.addEventListener('keyup',testfunc, false);
        var textarea = S('frm_body');
        main = document.getElementById('frm_body');
        if (main) {
            main.parentNode.insertBefore(previewArea, main);
        }
        
    }
    
    function testfunc(event) {
        if('previewArea' == event.target.id) {
            textarea = S('frm_body');
            textarea.value = event.target.innerHTML;
        }
    }
    createPreviewArea();
}

